package filter;

import java.io.IOException;
import java.util.Date;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;

/**
 * Servlet Filter implementation class TraceFilter
 */
@WebFilter("/*")
public class TraceFilter implements Filter {

		public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws ServletException, IOException {
			HttpServletRequest req = (HttpServletRequest)request;
			System.out.println(req.getRemoteHost() + " tried to access " +
			req.getRequestURL() + " on "+new Date() + ".");
			chain.doFilter(request,response);
		}
		
		public void init(FilterConfig config) throws ServletException {}
		
		public void destroy() {}

}
